using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_PrescMap : EntityTypeConfiguration<SO_Presc>
    {
        public SO_PrescMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.Date, t.Physician });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Patient__)
                .HasMaxLength(6);

            this.Property(t => t.Patient_Name)
                .HasMaxLength(60);

            this.Property(t => t.Subject)
                .HasMaxLength(50);

            this.Property(t => t.Physician)
                .IsRequired()
                .HasMaxLength(35);

            // Table & Column Mappings
            this.ToTable("SO_Presc");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Patient__).HasColumnName("Patient_#");
            this.Property(t => t.Patient_Name).HasColumnName("Patient_Name");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.Physician).HasColumnName("Physician");
        }
    }
}
